import { LoginResponseData, RuleForm, SendRegisterOrLoginCaptchaResponseData, mobileForm } from "@renderer/interface/login";
import http from "@renderer/utils/request";

// 枚举接口地址
enum API {
	LOGININBYJSON = '/u/loginByJson', // 用户登录
	CAPTCHAIMAGE = '/captcha/image', // 图形验证码
	SENDREGISTERORLOGINCAPTCHA = '/captcha/sendRegisterOrLoginCaptcha', // 获取手机验证码
	LOGINBYMOBILE = '/u/loginByMobile', // 手机验证码登录
}

export const postLoginByJsonAPI = (data: RuleForm) => http.post<LoginResponseData>(API.LOGININBYJSON, data)
export const getCaptchaImageAPI = (key: string) => http.get<ArrayBuffer>(API.CAPTCHAIMAGE, { key }, { responseType: 'arraybuffer' })
export const getSendRegisterOrLoginCaptchaAPI = (mobile: string) => http.get<SendRegisterOrLoginCaptchaResponseData>(API.SENDREGISTERORLOGINCAPTCHA + `?mobile=${mobile}`)
export const postLoginByMobileAPI = (data: mobileForm) => http.post<LoginResponseData>(API.LOGINBYMOBILE, data)